<?php

/***************************************************************************
Jupiter Content System @ Jupiterportal.org
 
Copyright (C) 2005-2007 Cosmin Flavius (highstrike@gmail.com)
Copyright (C) 2008-2009 George Mark (gmark@jupiterportal.org)

This program is free software; you can redistribute it and/or modify it under the terms of the GNU 
General Public License as published by the Free Software Foundation; either version 3 of the License, 
or (at your option) any later version.

More Info About The License At http://www.gnu.org/copyleft/gpl.html
****************************************************************************/

//-----------------------------------------------------------------
//  Define Variables
//-----------------------------------------------------------------

if(!isset($content_stats)) $content_stats = NULL;

//-----------------------------------------------------------------
//  Number of members
//-----------------------------------------------------------------

$total_members = $db->getInfo_countRows("users");

//-----------------------------------------------------------------	
//  Last registered user
//-----------------------------------------------------------------

$last_user = $db->getLine("SELECT id, username FROM users ORDER BY id DESC LIMIT 1");

//-----------------------------------------------------------------	
//  Total Topics And Posts
//-----------------------------------------------------------------

$TotalTopicsCount = $db->getInfo_countRows("forum_topics","type != 3");
$TotalPostsCount = $db->getInfo_countRows("forum_replies");

//-----------------------------------------------------------------
//  Load Live Members Table
//-----------------------------------------------------------------

$members = $db->getTable("SELECT user_id, user, user_authorization FROM online WHERE type = 'live' AND status = 'member'");

//-----------------------------------------------------------------
//  Current Admin Team Online
//-----------------------------------------------------------------

$total_admin = $db->getInfo_countRows("users","authorization = '2' OR authorization = '3' OR authorization = '4'");

//-----------------------------------------------------------------
//  Make a foreach to separate the results
//-----------------------------------------------------------------

if($members != FALSE)
{
	
	foreach($members as $idx=>$member)
	{
		If($member['user_authorization'] == 6) $color = "purple";
		If($member['user_authorization'] == 5) $color = "gold";
		If($member['user_authorization'] == 4) $color = "blue";
		If($member['user_authorization'] == 3) $color = "red";
		If($member['user_authorization'] == 2) $color = "green";
		If($member['user_authorization'] == 1) $color = "#606060";
				
		$content_stats .= "<a href='$PHP_SELF?n=modules/users&a=1&d={$member['user_id']}' title='".find_authorization($member['user_authorization'])."'><font style='font-weight:normal' color='$color'>{$member['user']}</font></a>, ";
	}

	$content_stats .= "end of coma";

	$content_stats = str_replace(', end of coma', "", $content_stats);
}
else $content_stats = "No Members Online.";

//-----------------------------------------------------------------
//  Create Layout
//-----------------------------------------------------------------

?>
<table><tr><td></td></tr></table>

<table class='main' cellpadding='4' cellspacing='1'>
<tr class='head'>
<td colspan='2'><?= $language['Statistics title'] ?></td>
</tr>
<tr class='bottom'>
<td><?= $language['Statistics desc'] ?></td>
<td><?= $language['Statistics desc1'] ?></td>
</tr>
<tr class='con1'>
<td rowspan='2' valign='top' width='110px'>
	<table class='main' cellpadding='4' cellspacing='1'>
	<tr class='empty'><td><img src='templates/<?= $template ?>/images/authorization/4.gif' border='0' alt='<?= $language['Statistics desc2'] ?>'> <?= $language['Statistics desc2'] ?></td></tr>
	<tr class='empty'><td><img src='templates/<?= $template ?>/images/authorization/3.gif' border='0' alt='<?= $language['Statistics desc3'] ?>'> <?= $language['Statistics desc3'] ?></td></tr>
	<tr class='empty'><td><img src='templates/<?= $template ?>/images/authorization/2.gif' border='0' alt='<?= $language['Statistics desc4'] ?>'> <?= $language['Statistics desc4'] ?></td></tr>
	<tr class='empty'><td><img src='templates/<?= $template ?>/images/authorization/1.gif' border='0' alt='<?= $language['Statistics desc5'] ?>'> <?= $language['Statistics desc5'] ?></td></tr>
	</table>
</td>
<td>
<?= $language['Statistics desc6'] ?> <b><?= $TotalTopicsCount ?></b> <?= $language['Statistics desc7'] ?> <b><?= $TotalPostsCount ?></b> <?= $language['Statistics desc8'] ?><br />
<?= $language['Statistics desc9'] ?> <b><?= $total_members ?></b> <?= $language['Statistics desc10'] ?> <?= $config['website_name'] ?><br />
<?= $language['Statistics desc11'] ?> <a href='$PHP_SELF?n=modules/users&a=1&d=<?= $last_user['id'] ?>'><?= $last_user['username'] ?></a><br />
</td>
</tr>
<tr class='con1'>
<td valign='top'>
<?= $language['Statistics desc12'] ?> <b><?= $total_admin ?></b><br />
<?= $language['Statistics desc13'] ?> <b><?= $misc['totalonline'] ?></b><br />
<?= $language['Statistics desc14'] ?> <?= $content_stats ?><br />
</td>
</tr>
</table>